package lambda.string;

public class Test {
    public static void main(String[] args) {
        String s1="http://www.tedu.cn";
        String s2="www.tarena.com.cn";
        String n1=getHostName(s1);
        String n2=getHostName(s2);
        System.out.println(n1);//tedu
        System.out.println(n2);//tarena
    }

    public  static  String getHostName(String url){
//                         4
//                         v
//        String s2 = "www.tarena.com.cn";
        int start = url.indexOf(".")+1;//4
        int end = url.indexOf(".",start);
        String sub = url.substring(start,end);
        return sub;
    }
}
